import React, { Component } from 'react';
import { Spin, Icon } from 'antd';

import API from '../../../api/auth/index';

const loadingIcon = <Icon type="loading" style={{ fontSize: 40 }} spin />;

export default class LoadingDocView extends Component {
  synologyLogin = async () => {
    const response = await API.getSynologySid();
    const { code, data } = response;
    if (code === 1) {
      window.location.href = `https://cloud.pansheng.com/?launchApp=SYNO.SDS.PDFViewer.Application&_sid=${data}`;
    }
  }
  componentDidMount () {
    this.synologyLogin();
  }
  render () {
    return (
      <div
        className="loading-view"
        style={{
          height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center',
        }}
      >
        <Spin indicator={loadingIcon} />
      </div>
    );
  }
}
